package com.iss.card.view.mycard;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.iss.card.R;
import com.iss.card.common.ApplicationManager;
import com.iss.card.common.FunctionUtil;
import com.iss.card.common.IBackKeyListener;
import com.iss.card.model.UserInfo;
import com.iss.card.view.mycard.detail.CardDetailHistroyFragment;
import com.iss.card.view.mycard.detail.CardDetailMyCardFragment;
import com.iss.card.view.mycard.detail.CardDetailRuleDescriptionFragment;
import com.iss.card.view.mycard.detail.CardDetailStoreBrowseFragment;

public class MyCardDetailActivity extends FragmentActivity implements IBackKeyListener{

	private final static String TAG = "MyCardDetailActivity";
	private FragmentTabHost mTabHost;
	private UserInfo usrinInfo;
	private CardDetailMyCardFragment myCardFragment;
	private CardDetailStoreBrowseFragment storeBrowseFragment;
	private CardDetailHistroyFragment historyFragment;
	private CardDetailRuleDescriptionFragment ruleFragment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		usrinInfo = FunctionUtil.getCurrentLogInUser();
		CardBagModel cardBagInfoFormItem = (CardBagModel) getIntent().getSerializableExtra(ApplicationManager.INTENT_KEY);
		setContentView(R.layout.card_detail);
        mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
        Bundle bundle = new Bundle();
        bundle.putSerializable(ApplicationManager.KEY_MYCARD_BRIEF_CARD, cardBagInfoFormItem);
        
        myCardFragment = new CardDetailMyCardFragment();
        historyFragment = new CardDetailHistroyFragment();
        storeBrowseFragment = new CardDetailStoreBrowseFragment();
        ruleFragment = new CardDetailRuleDescriptionFragment();
        

        mTabHost.addTab(mTabHost.newTabSpec("MyCard").setIndicator(View.inflate(this, R.layout.mycard_mycard_button, null)),
        		myCardFragment.getClass(), bundle);
        mTabHost.addTab(mTabHost.newTabSpec("History").setIndicator(View.inflate(this, R.layout.mycard_history_button, null)),
        		historyFragment.getClass(), bundle);
        mTabHost.addTab(mTabHost.newTabSpec("Rule").setIndicator(View.inflate(this, R.layout.mycard_rule_button, null)),
        		ruleFragment.getClass(), bundle);
        mTabHost.addTab(mTabHost.newTabSpec("Stores").setIndicator(View.inflate(this, R.layout.mycard_browse_button, null)),
        		storeBrowseFragment.getClass(), bundle);
        
		String cardName = cardBagInfoFormItem.getCardName();
		Button btnReturn = (Button) findViewById(R.id.return_button);
		TextView tvName = (TextView)findViewById(R.id.job_name_val);
		tvName.setTextSize(13.0f);
		tvName.setText(cardName);
		
		btnReturn.setVisibility(View.VISIBLE);
		btnReturn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
	@Override
	public void cancelUpdate(Object... params) {
		// TODO Auto-generated method stub
		
	}
	
}
